<?php declare(strict_types=1);

namespace App\Dao;

use App\Model\Event;
use Hyperf\Database\Model\Builder;
use Hyperf\Database\Model\Model;
use Hyperf\Di\Annotation\Inject;

class EventDao
{
    /**
     * @Inject()
     * @var Event
     */
    protected Event $eventModel;


    /**
     * 获取详情，和提交情况
     * @param int $eventId
     * @return Builder|Model|object|null
     */
    public function info(int $eventId)
    {
        return $this->eventModel::query()->select(['id','name','created_by','receiver','deathline','start_submit_at'])
            ->where('id','=', $eventId)->with('info')->get();
    }

    public function delEvent(int $eventId)
    {
        return $this->eventModel::query()->where('id','=' , $eventId)->delete();
    }
}